home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / javax / swing / Scrollable.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  4.6 KB  |  116 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)Scrollable.java    1.4 98/08/26
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package javax.swing;
  16.  
  17. import java.awt.Dimension;
  18. import java.awt.Rectangle;
  19.  
  20.  
  21. /** 
  22.  * An interface that provides information to a scrolling container
  23.  * like JScrollPane.  A complex component that's likely to be used 
  24.  * as a viewin a JScrollPane viewport (or other scrolling container) 
  25.  * should implement this interface.
  26.  * 
  27.  * @see JViewport
  28.  * @see JScrollPane
  29.  * @see JScrollBar
  30.  * @version 1.4 08/26/98
  31.  * @author Hans Muller
  32.  */
  33. public interface Scrollable  
  34. {
  35.     /**
  36.      * Returns the preferred size of the viewport for a view component.
  37.      * For example the preferredSize of a JList component is the size
  38.      * required to acommodate all of the cells in its list however the
  39.      * value of preferredScrollableViewportSize is the size required for
  40.      * JList.getVisibleRowCount() rows.   A component without any properties
  41.      * that would effect the viewport size should just return 
  42.      * getPreferredSize() here.
  43.      * 
  44.      * @return The preferredSize of a JViewport whose view is this Scrollable.
  45.      * @see JViewport#getPreferredSize
  46.      */
  47.     Dimension getPreferredScrollableViewportSize();
  48.  
  49.  
  50.     /**
  51.      * Components that display logical rows or columns should compute
  52.      * the scroll increment that will completely expose one new row
  53.      * or column, depending on the value of orientation.  Ideally, 
  54.      * components should handle a partially exposed row or column by 
  55.      * returning the distance required to completely expose the item.
  56.      * <p>
  57.      * Scrolling containers, like JScrollPane, will use this method
  58.      * each time the user requests a unit scroll.
  59.      * 
  60.      * @param visibleRect The view area visible within the viewport
  61.      * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  62.      * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  63.      * @return The "unit" increment for scrolling in the specified direction
  64.      * @see JScrollBar#setUnitIncrement
  65.      */
  66.     int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction);
  67.  
  68.  
  69.     /**
  70.      * Components that display logical rows or columns should compute
  71.      * the scroll increment that will completely expose one block
  72.      * of rows or columns, depending on the value of orientation. 
  73.      * <p>
  74.      * Scrolling containers, like JScrollPane, will use this method
  75.      * each time the user requests a block scroll.
  76.      * 
  77.      * @param visibleRect The view area visible within the viewport
  78.      * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  79.      * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  80.      * @return The "block" increment for scrolling in the specified direction.
  81.      * @see JScrollBar#setBlockIncrement
  82.      */
  83.     int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);  
  84.     
  85.  
  86.     /**
  87.      * Return true if a viewport should always force the width of this 
  88.      * Scrollable to match the width of the viewport.  For example a noraml 
  89.      * text view that supported line wrapping would return true here, since it
  90.      * would be undesirable for wrapped lines to disappear beyond the right
  91.      * edge of the viewport.  Note that returning true for a Scrollable
  92.      * whose ancestor is a JScrollPane effectively disables horizontal
  93.      * scrolling.
  94.      * <p>
  95.      * Scrolling containers, like JViewport, will use this method each 
  96.      * time they are validated.  
  97.      * 
  98.      * @return True if a viewport should force the Scrollables width to match its own.
  99.      */
  100.     boolean getScrollableTracksViewportWidth();
  101.  
  102.     /**
  103.      * Return true if a viewport should always force the height of this 
  104.      * Scrollable to match the height of the viewport.  For example a 
  105.      * columnar text view that flowed text in left to right columns 
  106.      * could effectively disable vertical scrolling by returning
  107.      * true here.
  108.      * <p>
  109.      * Scrolling containers, like JViewport, will use this method each 
  110.      * time they are validated.  
  111.      * 
  112.      * @return True if a viewport should force the Scrollables height to match its own.
  113.      */
  114.     boolean getScrollableTracksViewportHeight();
  115. }
  116.